package Month07.day22;

import java.util.Arrays;

public class DemoKuaiPai {
    public static void main(String[] args) {
        int[] ints = new int[]{6,5,2,9,1,3,8,4,7,10};
       newArr(ints,0, ints.length-1);
        System.out.println(Arrays.toString(ints));
    }
    private static void newArr(int[] arr,int left,int right){
   if (left>right){
       return;
   }
   int left0=left;
   int right0=right;
   int baseNumber=arr[left0];
   while (left!=right){
       while (arr[right]>=baseNumber&&right>left){
           right--;
       }
       while (arr[left]<=baseNumber&&right>left){
           left++;
       }
       int temp=arr[left];
       arr[left]=arr[right];
       arr[right]=temp;
   }
   int temp=arr[left];
   arr[left]=arr[left0];
   arr[left0]=temp;
   newArr(arr,left0,left-1);
   newArr(arr,left+1,right0);
    }
}
